import request from '@/utils/request'
import CryptoJS from 'crypto-js'

export function fetchUserList(query) {
  return request({
    url: '/backend/user/list',
    method: 'get',
    params: query
  })
}

export function login(data) {
  data.password = CryptoJS.SHA1(data.password.toString()).toString()
  return request({
    url: '/backend/account/login',
    method: 'post',
    data: data
  })
}

export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'post',
    data: {
      token: token
    }
  })
}

export function logout() {
  return request({
    url: '/auth/logout',
    method: 'post'
  })
}

export function fetchUserDetail(uid) {
  return request({
    url: '/backend/user/detail',
    method: 'get',
    params: {
      uid: uid
    }
  })
}
